<?php

use yii\db\Migration;

/**
 * Class m190911_025012_member
 */
class m190911_025012_member extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB COMMENT="用户表"';
        $this->createTable('{{%member}}', [
            'id' => $this->primaryKey(),
            'username' => $this->string()->comment('昵称'),
            'mobile' => $this->string()->notNull()->unique()->comment('电话'),
            'hry_member_id' => $this->Integer()->unique()->comment('好融艺会员id'),
            'head_img' => $this->string()->unique()->comment('头像'),
            'birthday' => $this->string()->comment('生日'),
            'sex' => $this->smallInteger()->defaultValue(1)->comment('性别，1-男，2-女'),
            'password' => $this->string()->notNull()->comment('登录密码'),
            'salt' => $this->string(16)->comment('盐'),
            'token' => $this->string()->unique(),
            'experience' => $this->Integer()->defaultValue(0)->comment('经验值'),
            'integral' => $this->Integer()->defaultValue(0)->comment('积分'),
            'province_id' => $this->Integer()->comment('省ID'),
            'city_id' => $this->Integer()->comment('城市ID'),
            'is_auth' => $this->smallInteger()->notNull()->defaultValue(1)->comment('是否管理员，发帖，评论权限 1否2是'),
            'status' => $this->smallInteger()->notNull()->defaultValue(1),
            'created_at' => $this->integer()->notNull(),
            'updated_at' => $this->integer()->notNull(),
            'deleted_at' => $this->integer(),
        ],$tableOptions);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('{{%member}}');
        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m190911_025012_member cannot be reverted.\n";

        return false;
    }
    */
}
